# vue-cli 3.0引入jquery

  1. 安装jquery

    npm install jquery --save

  2. 修改.eslintrc.js文件,找到env,在里面添加jquery:true,默认应该已经有了node:true

    env:{
        node: true,
        jquery: true
    }
    

    1553764585828

  3. 修改vue.config.js文件,在头部定义const webpack = require('webpack'),然后在module.exports中添加:

    configureWebpack: {
        plugins: [
            new webpack.ProvidePlugin({
                $: 'jquery',
                jQuery: 'jquery',
                'windows.jQuery': 'jquery'
            })
        ]
    }
    

    1553764519087

  4. main.js中增加import $ from jquery,即可:

    1553764682700